import axios from '../axios';

/** *********获取服务产品交易状态******** */
export const checkTradable = () => axios.post('dz-mall/server/checkTradable');

/** *********获取服务产品列表******** */
export const getServerList = (shelfStatus) => axios.post('dz-mall/server/list', {
  // shelfStatus上下架状态，非必须
  shelfStatus
});

/** *********获取投顾服务产品******** */
export const getServerById = (productId) => axios.post('dz-mall/server/selectById', {
  productId
});

/** *********获取投顾服务产品******** */
export const getServerByCode = (productCode) => axios.post('dz-mall/server/selectByCode', {
  productCode
});

/** *********获取用户的三要素******** */
export const getProductElig = (productCode) => axios.post('dz-mall/server/getProductElig', {
  productCode
});

/** *********获取订单生效日期******** */
export const getServerStartDate = (productCode, priceId) => axios.post('dz-mall/server/getEffectiveDate', {
  productCode,
  priceId
});

/** *********获取服务产品持仓数据******** */
export const getServerPosition = (productCode) => axios.post('dz-mall/server/getPosition', {
  productCode// 非必须
});

/** *********服务产品下订单******** */
export const doServerOrder = (params) => axios.post('dz-mall/order/server/buy', {
  productCode: params.productCode,
  priceId: params.priceId,
  totalPrice: params.totalPrice,
  orderChannel: params.orderChannel,
  groupId: params.groupId,
  originFrom: params.originFrom,
  mobile: params.mobile,
  qq: params.qq,
  wx: params.wx
});

/** *********获取服务产品当天订单******** */
export const getServerTodayOrders = (productCode) => axios.post('dz-mall/order/server/today', {
  productCode
});

/** *********获取服务产品历史订单******** */
export const getServerHistoryOrders = (dayNum, productCode) => axios.post('dz-mall/order/server/history', {
  dayNum,
  productCode
});

/** *********撤销服务产品订单******** */
export const doServerRevoke = (params) => axios.post('dz-mall/order/server/revoke', {
  productCode: params.productCode,
  allotNo: params.allotNo,
  coSerialNo: params.coSerialNo
});

/** *********获取服务产品类型******** */
export const getGroupType = (groupId) => axios.post('dz-mall/server/getGroupType', {
  groupId
});

/** ********************************************************************************************* */

/** *********获取互联网投顾产品列表******** */
export const getServerIaList = (shelfStatus) => axios.post('dz-mall/server/iaList', {
  // shelfStatus上下架状态，非必须
  shelfStatus
});

/** *********获取互联网投顾产品数据******** */
export const getIAProductByCode = (productCode) => axios.post('dz-mall/server/getIAProductByCode', {
  productCode
});

/** *********获取互联网投顾产品价格******** */
export const getIAProdPriceByCode = (productCode) => axios.post('dz-mall/server/getIAProdPriceByCode', {
  productCode
});

/** *********获取互联网投顾产品三要素信息******** */
export const getIAProductElig = (productCode) => axios.post('dz-mall/server/getIAProductElig', {
  productCode
});

/** *********互联网投顾产品适当性协议书留痕******** */
export const signAdequacyAgreement = (productCode, content) => axios.post('dz-mall/server/signAdequacyAgreement', {
  productCode,
  content
});

/** *********互联网投顾产品说明书等留痕******** */
export const signIAAgreement = (productCode, agreementId, content, batchNo) => axios.post('dz-mall/server/signAgreement', {
  stockCode: productCode,
  agreementId,
  content,
  batchNo // 非必填，记录该笔订单流水号
});

/** *********获取订单生效日期******** */
export const getIAEffectiveDate = (productCode, priceId) => axios.post('dz-mall/server/getIAEffectiveDate', {
  productCode,
  priceId
});

/** *********互联网投顾产品下单******** */
export const buyIAProd = (params) => axios.post('dz-mall/order/server/buyIAProd', {
  productCode: params.productCode,
  priceId: params.priceId,
  totalPrice: params.totalPrice,
  mobile: params.mobile,
  paymentWay: params.paymentWay,
  orderChannel: params.orderChannel,
  originFrom: params.originFrom,
  recommendId: params.recommendId, // 拓展人id，非必须
  questionId: params.questionId,
  couponId: params.couponId,
  openId: params.openId, // 非必传
  tradeType: params.tradeType
});

/** *********互联网投顾产品通知优品修改问答状态******** */
export const notifyWDSignStatus = (productCode, questionId) => axios.post('dz-mall/server/syncUPSignStatus', {
  productCode,
  questionId
});

/** *********互联网投顾产品通过h5活动免费试用******** */
export const doIAProbe = (params) => axios.post('dz-mall/order/server/iaProbe', {
  productCode: params.productCode,
  orderChannel: params.orderChannel,
  originFrom: params.originFrom,
  beginDate: params.beginDate, // 开始日期,格式yyyy-MM-dd
  endDate: params.endDate, // 结束日期,格式yyyy-MM-dd
  mobile: params.mobile,
  qq: params.qq,
  wx: params.wx,
  couponId: params.couponId,
  type: 1 // 1销券；0取消销券
});

/** *********互联网投顾产品通知优品修改问答状态******** */
export const updateWxOrderFail = (orderId, msg) => axios.post('dz-mall/order/server/updateIAOrderWxPayFailById', {
  orderId,
  message: msg
});

/** *********互联网投顾产品通知优品修改问答状态******** */
export const getWxPaymentEnable = () => axios.post('dz-mall/order/server/getWxPaymentEnable');

/** *********互联网投顾确认订单并支付******** */
export const updateWxOrderSuccess = (orderId) => axios.post('dz-mall/order/server/getIAOrderWxPayStatusById', {
  orderId
});

/** *********互联网投顾确认订单并支付******** */
export const payIAOrder = (orderId) => axios.post('dz-mall/order/server/payIAOrder', {
  orderId
});

/** *********获取互联网投顾产品今日订单******** */
export const getIATodayOrders = () => axios.post('dz-mall/order/server/getUserTodayIAOrders');

/** *********获取互联网投顾产品今日订单******** */
export const getIAHistoryOrders = (dayNum) => axios.post('dz-mall/order/server/getUserHistoryIAOrders', {
  dayNum
});

/** *********获取互联网投顾产品持仓数据******** */
export const getIAServerPosition = (productCode) => axios.post('dz-mall/order/server/getPositionOrders', {
  productCode// 非必须
});

/** *********互联网投顾订单撤单******** */
export const revokeIAOrder = (orderId) => axios.post('dz-mall/order/server/revokeOrder', {
  orderId
});

/** *********互联网投顾问答判断是否签署适当性******** */
export const checkAdequacyStatus = () => axios.post('dz-mall/server/checkQuestionAdequacyStatus');

/** *********单篇文章 获取文章相关基本信息******** */
export const getArticleById = (articleId) => axios.post('dz-mall/server/getArticleById', {
  articleId
});
/** *********单篇文章 判断是否签署过三要素******** */
export const checkArticleAdequacy = (articleId) => axios.post('dz-mall/server/checkArticleAdequacy', {
  articleId
});

/** *********单篇文章 适当性协议签署******** */
export const signArticleAdequacyAgreement = (params) => axios.post('dz-mall/server/signArticleAdequacyAgreement', {
  articleId: params.articleId,
  content: params.content,
  batchNo: params.batchNo, // 非必传
  agreementId: params.agreementId // 非必传
});

/** *********单篇文章 协议签署******** */
export const signArticleAgreement = (params) => axios.post('dz-mall/server/signArticleAgreement', {
  articleId: params.articleId,
  content: params.content,
  batchNo: params.batchNo, // 非必传
  agreementId: params.agreementId // 非必传
});

/** *********单篇文章 查看待支付订单数据信息******** */
export const selectArticlePreOrder = (orderId) => axios.post('dz-mall/order/server/selectArticlePreOrder', {
  orderId
});

/** *********单篇文章 订单支付******** */
export const buyArticle = (params) => axios.post('dz-mall/order/server/buyArticle', {
  productCode: params.productCode,
  orderId: params.orderId,
  totalPrice: params.totalPrice,
  mobile: params.mobile,
  paymentWay: params.paymentWay,
  orderChannel: params.orderChannel,
  originFrom: params.originFrom,
  recommendId: params.recommendId, // 拓展人id，非必须
  couponId: params.couponId,
  openId: params.openId, // 非必传
  tradeType: params.tradeType
});
/** *********互联网投顾 判断是否开通证券账户******** */
export const checkClientStkAcct = () => axios.post('dz-mall/order/server/checkClientStkAcct');

/** *********单笔提佣 签约******** */
export const signZLB = (params) => axios.post('dz-mall/order/server/signZLB', {
  productCode: params.productCode,
  qa: params.qa, // 知识测评答案
  originFrom: params.originFrom,
  orderChannel: params.orderChannel,
  batchNo: params.batchNo
});

/** *********单笔提佣 解约******** */
export const cancelZLB = (params) => axios.post('dz-mall/order/server/cancelZLB', {
  productCode: params.productCode,
  originFrom: params.originFrom,
  orderChannel: params.orderChannel,
  batchNo: params.batchNo
});

/** *********单笔提佣 签约查询******** */
export const checkZLB = (productCode) => axios.post('dz-mall/order/server/checkZLB', {
  productCode
});

/** *********单笔提佣 知识测评问卷******** */
export const getZLBQAs = () => axios.post('dz-mall/agreement/getZLBQuestionnaire', {});

/** *********服务产品购买消息推送 数据******** */
export const getServerProdMsg = (productCode) => axios.post('dz-mall/server/queryServerProdMsg', {
  productCode
});

/** *********随日融 领取优惠券******** */
export const getCoupon = (promotionId) => axios.post('dz-mall/promotion/getCoupon', {
  promotionId,
  originFrom: '随日融'
});

/** *********随日融 有领取资格的优惠券******** */
export const getWithdayAccess = () => axios.post('dz-mall/promotion/getFollowWaitReceive');

/** *********随日融 获取可使用优惠券******** */
export const getWithdayCoupons = () => axios.post('dz-mall/promotion/getClientFollowCoupon', {
  valid: 1
});

/** *********随日融 获取不可用或已过期优惠券******** */
export const getWithdayInvalidCoupons = () => axios.post('dz-mall/promotion/getClientFollowCoupon', {
  valid: 0
});

/** *********增利宝 签解约协议留痕pdf查询******** */
export const getAgreementPDF = () => axios.post('dz-mall/order/server/getAgreementPDF');

/** *********股神大赛参赛用户是否可订阅服务******** */
export const gsdsTrialCheck = (fundAccount, productCode) => axios.post('dz-mall/server/gsdsTrialCheck', {
  fundAccount,
  productCode
});

/** *********股神大赛参赛用户订阅服务******** */
export const gsdsTrialProdBuy = (params) => axios.post('dz-mall/server/gsdsTrialProdBuy', {
  fundAccount: params.fundAccount,
  productCode: params.productCode,
  startDate: params.startDate,
  endDate: params.endDate
});

/** *********东泰组合试用是否试用资格******** */
export const checkRegister = (fundAccount, productCode) => axios.post('dz-mall/server/promotion/checkRegister', {
  fundAccount,
  productCode
});

/** *********东泰组合是否已领取免费试用******** */
export const checkProbation = (tel, fundAccount, productCode) => axios.post('dz-mall/server/promotion/checkProbation', {
  tel,
  fundAccount,
  productCode
});

/** *********东泰组合免费试用******** */
export const promotionBuy = (params) => axios.post('dz-mall/server/promotion/promotionBuy', {
  tel: params.tel,
  fundAccount: params.fundAccount,
  productCode: params.productCode,
  startDate: params.startDate, // 非必传，有后台来计算起始日期
  days: params.days // 非必传，有后台来计算起始日期
});

/** *********小宝plus会员、港股level2等活动服务产品订单购买回调******** */
export const plusBuyNotify = (priceId, orderId, activityType) => axios.post('dz-mall/server/plus/buyNotify', {
  priceId,
  orderId,
  activityType
});

/** *********小宝plus会员、港股level2等活动服务产品订单撤单回调******** */
export const plusRevokeNotify = (coSerialNo, activityType) => axios.post('dz-mall/server/plus/revokeNotify', {
  coSerialNo,
  activityType
});

/** *********小宝plus会员、港股level2等活动服务产品订单撤单回调******** */
export const iaPlusRevokeNotify = (orderId, activityType) => axios.post('dz-mall/server/plus/revokeIANotify', {
  orderId,
  activityType
});

/** *********获取用户所有服务产品优惠券信息******** */
export const getMyCouponList = () => axios.post('dz-mall/promotion/getClientCoupon');

/** *********获取用户特定服务产品优惠券信息******** */
export const getCouponByProduct = (productCode, productType, priceType) => axios.post('dz-mall/promotion/getClientCouponByProduct', {
  productCode,
  productType, // 非必传
  priceType // 非必传
});

/** *********通用h5活动判断资格,返回对应的优惠券ID******** */
export const checkQualification = (productCode, activityId, date) => axios.post('dz-mall/server/activity/checkQualification', {
  productCode, // 必传
  activityId, // 非必传，有的话就传
  date // 非必传
});

/** *********通用h5活动优惠券销券******** */
export const couponNotify = (couponId, type) => axios.post('dz-mall/server/activity/couponNotify', {
  couponId, // 必传
  type // 非必传，销券类型:1-销券/0-取消销券
});

/** *********获取通用h5活动订单列表******** */
export const getProbeOrders = () => axios.post('dz-mall/order/server/getProbe');

/** *********通用h5活动下单******** */
export const doProbe = (params) => axios.post('dz-mall/order/server/probe', {
  productCode: params.productCode,
  orderChannel: params.orderChannel,
  originFrom: params.originFrom,
  beginDate: params.beginDate, // 开始日期,格式yyyy-MM-dd
  endDate: params.endDate, // 结束日期,格式yyyy-MM-dd
  mobile: params.mobile,
  qq: params.qq,
  wx: params.wx
});